package com.fone.player.activity;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.widget.Toast;

import com.fone.player.util.ActivityQueue;

/**
 * A basic Activity that have provided some common features. Anyone activity
 * that extends BaseActivity will be pushed into a ActivityQueue automatically
 * 
 * @author kongxiaojun
 * @since 2014-5-14
 */
public abstract class BaseActivity extends Activity implements Stackable {

	protected Context mContext;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mContext = getApplicationContext();
		push();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		pop();
	}

	@Override
	public void push() {
		ActivityQueue.pushActivity(this);
	}

	@Override
	public void pop() {
		ActivityQueue.popActivity(this);
	}
	
	/**
	 * Toast短显示
	 * @param int pResId
	 */
	protected void showShortToast(int pResId) {
		showShortToast(mContext.getString(pResId));
	}
	
	/**
	 * Toast短显示
	 * @param String pMsg
	 */
	protected void showShortToast(String pMsg) {
		Toast.makeText(mContext, pMsg, Toast.LENGTH_SHORT).show();
	}
	
	/**
	 * Toast长显示
	 * @param int pResId
	 */
	protected void showLongToast(int pResId) {
		showLongToast(mContext.getString(pResId));
	}
	
	/**
	 * Toast长显示
	 * @param String pMsg
	 */
	protected void showLongToast(String pMsg) {
		Toast.makeText(mContext, pMsg, Toast.LENGTH_LONG).show();
	}

	/**
	 * 异地登录回调登陆
	 */
	public void distanceLoginCallback(){}

}
